import { vitePluginFakeServer } from 'vite-plugin-fake-server';

export default (env: any) => {
  const { VITE_MOCK, VITE_APP_BASE_API } = env;
  console.log('VITE_MOCK', VITE_MOCK);
  console.log('VITE_APP_BASE_API', VITE_APP_BASE_API);
  const plugin: any[] = [];
  if (VITE_MOCK) {
    console.log('use mock');
    // mock支持
    plugin.push(
      vitePluginFakeServer({
        basename: VITE_APP_BASE_API,
        logger: true,
        watch: true,
        include: 'mock',
        infixName: false,
        enableProd: false
      })
    );
  }
  return plugin;
};
